package com.wechat.third;

import java.text.DateFormat;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Date;

/**
 * @author
 * @date 2018/12/12
 */
public class PrnCurrentTime implements Runnable {

	/**
	 * @param args
	 */
	public static void main(String[] args) {
		PrnCurrentTime p = new PrnCurrentTime();
		new Thread(p).start();
	}

	@Override
	public void run() {
		while(true){
			try {
				Thread.sleep(5000);
			} catch (InterruptedException e) {
				e.printStackTrace();
			}
			Date now = new Date();
			String startTime="2018-12-12 22:20:50";//数据库取得时间
			DateFormat df = new SimpleDateFormat("yyyy-MM-dd hh:mm:ss");
			try {
				Long diff=(now.getTime()-df.parse(startTime).getTime())/1000;
				if(diff<=5){
					System.out.println("发mq");
				}

			} catch (ParseException e) {
				e.printStackTrace();
			}

		}

	}
}
